package com.download.web.service.impl;

import com.download.web.entity.SysNavBar;
import com.download.web.mapper.SysNavBarMapper;
import com.download.web.service.ISysNavBarService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author cmy
 * @since 2019-02-20
 */
@Service
public class SysNavBarServiceImpl extends ServiceImpl<SysNavBarMapper, SysNavBar> implements ISysNavBarService {

    @Resource
    private SysNavBarMapper sysNavBarMapper;

    @Override
    public List<SysNavBar> selectTypeName(int id) {
        try {
            List<SysNavBar> str=new ArrayList<>();
            SysNavBar nav=sysNavBarMapper.selectById(id);
            str.add(nav);
            if(nav!=null&&nav.getParentId()!=0){
                SysNavBar parNav=sysNavBarMapper.selectById(nav.getParentId());
                str.add(parNav);
            }
            return str;
        }catch (Exception e){
             e.printStackTrace();
             return null;
        }
    }

    @Override
    public void updateNameById(String name, Integer id) {
        sysNavBarMapper.updateNameById(name,id);
    }
}
